﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using JeanFish.Common;

namespace JeanFish.UnitTest.Common
{
    [TestClass]
    public class ConvertHelperTest
    {
        [TestMethod]
        public void ConvertByBaseTest()
        {
            string source = "10";
            string target=source.ToTargetBase(10, 2);
            Assert.AreEqual("1010", target);
            string target2 = source.ToTargetBase(2, 16);
            Assert.AreEqual("2", target2);
            string target3 = source.ToTargetBase(10, 16);
            Assert.AreEqual("a", target3);
            string target4 = "a".ToTargetBase(16, 10,4);
            Assert.AreEqual("0010", target4);
        }

        [TestMethod]
        public void ToBinaryArrayTest()
        {
            int source = 10;
            Assert.AreEqual(string.Join("",source.ToBinaryArray(5)),string.Join("",new int[]{0,1,0,1,0}));
        }
    }
}
